package cn.usian.controller;

import cn.usian.pojo.Student;
import cn.usian.service.StudentService;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class Login {

    @Autowired
    private StudentService studentService;

    /**
     * 登录
     * @param student
     * @param session
     * @return
     */
    @RequestMapping("login")
    public String login(Student student, HttpSession session){
        Student student1=studentService.findStudentAndPwd(student);
        if (student1!=null){
            session.setAttribute("student",student1);
            return "redirect:/findAll";
        }
        return "login";
    }

}
